﻿#region Imports
using IntelliSearch.Utilities;
using System;
using System.Linq;
#endregion

namespace IntelliSearch.Models
{
    public class Contacts
    {
        #region Properties
        public string Id { get { return DateTime.Now.ToString("G"); } }

        private string fName;
        public string FName
        {
            get { return fName.ToFormattedNullString(); }
            set { fName = value; }
        }

        private string mName;
        public string MName
        {
            get { return mName.ToFormattedNullString(); }
            set { mName = value; }
        }

        private string lName;
        public string LName
        {
            get { return lName.ToFormattedNullString(); }
            set { lName = value; }
        }

        public string NickName { get; set; }

        public string PhoneNum { get; set; }
        public eDisplayFormat DisplayFormat { get; set; }

        public string Initials
        {
            get
            {
                return CommonUtilities.CreateInitialsFromName(".", FName, MName, LName);
            }
        }

        public string FullName
        {
            get
            {
                string fullName = "";

                switch (DisplayFormat)
                {
                    case eDisplayFormat.FirstNameFirst:
                        fullName = FName + (MName.Length > 0 ? " " + MName : "") + " " + LName;
                        break;
                    case eDisplayFormat.LastNameFirst:
                        fullName = LName + ", " + FName + (MName.Length > 0 ? " " + MName : "");
                        fullName = "";
                        break;
                    default:
                        break;
                }

                return fullName + (!NickName.IsNullOrEmpty() ? " :: " + NickName.ToFormattedNullString() : "");
            }
        }
        #endregion

        #region Constructors
        public Contacts()
        {
            DisplayFormat = eDisplayFormat.FirstNameFirst;
        }
        #endregion
    }
}
